<template>
  <div class="left-block1">
    <div class="data-title">
      <a href="javascript:;" @click="download">工艺信息</a><label style="margin-left: 30px;color: aliceblue; font-size: 20px;">{{obj.craftsNumber}}</label>
    </div>
    <div  class="process-info">
      <el-form label-width="100px" class="wise-form" label-suffix="：">
        <el-row>
          <el-col :span="12">
            <el-form-item label="焊接位置">
              {{ obj.welderPosition }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="焊接方向">
              {{ obj.welderDirection }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="预热温度">
              {{ obj.temperature }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="坡口形势">
              {{ obj.bevelSituation }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="层间温度">
              {{ obj.layerTemperature }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="焊接厚度">
              {{ obj.weldingThickness }}
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div style="height: 140px; background: #161a3f">
        <el-table
          :data="tableData"
          border
          style="
            width: 100%;
            margin-bottom: 30px;
            height: 100%;
            background: #161a3f;
          "
          class="scroll-wrap"
        >
          <el-table-column prop="weldName" label="焊道" />
          <el-table-column prop="weldMethod" label="焊接方法" width="68px" />
          <el-table-column prop="weldingHeatInputMin" label="规格" width="60px">
            <template slot-scope="scope">
              {{ scope.row.specification }}
            </template>
          </el-table-column>
          <el-table-column
            prop="electricCurrentMin"
            label="电流(A)"
            width="60px"
          >
            <template slot-scope="scope">
              {{ scope.row.electricCurrentMin }}-{{
                scope.row.electricCurrentMax
              }}
            </template>
          </el-table-column>
          <el-table-column prop="voltageMin" label="电压(U)" width="60px">
            <template slot-scope="scope">
              {{ scope.row.voltageMin }}-{{ scope.row.voltageMax }}
            </template>
          </el-table-column>
          <el-table-column prop="weldingSpeedMin" label="焊接速度" width="60px">
            <template slot-scope="scope">
              {{ scope.row.weldingSpeedMin }}-{{ scope.row.weldingSpeedMax }}
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
<!--    <div v-else class="process-info">-->
<!--      <div class="nodata">暂无数据</div>-->
<!--    </div>-->
  </div>
</template>

<script>
import { postHandle } from '@/api'
import { downloadHandle } from '@/api'
export default {
  name: 'ProcessInformation',
  props: {
    equipCode: {
      type: String
    },
    newSpaceId: {
      type: String
    }
  },
  data() {
    return {
      tableData: [],
      obj: {}
    }
  },
  computed: {
    project() {
      return this.$store.state.project.object
    },
    entSpaceId() {
      return this.$store.getters.entSpaceId
    }
  },
  watch: {
    equipCode(val) {
      if (val) {
        this.getData()
      }
    },
    newSpaceId(val) {
      if (val && this.equipCode) {
        this.getData()
      }
    }
  },
  created() {
    if (this.project && this.project.spaceId && this.equipCode) {
      this.getData()
    }
  },
  methods: {
    getData() {
      postHandle(
        `/api/v1/welder-sbtx-second/identification-card-comb/get-equipment-by-craftsx`,
        {
          d: {
            filters: [
              {
                field: 'spaceId',
                operator: 'EQUALS',
                value: this.newSpaceId || this.project.spaceId
              },{
                field: 'entSpaceId',
                operator: 'EQUALS',
                value: this.entSpaceId  
              },
              { field: 'serialNum', operator: 'EQUALS', value: this.equipCode }
            ]
          }
        }
      ).then((res) => {
        this.obj = res.result.craftsInfo || {}
        this.tableData = res.result.weldInfoList
      })
    },
    download() {
      this.$router.push({
          name: "pdfreade",
          params:{
            pdfSrc: "",
        
          }
        });
      
      // downloadHandle(process.env.VUE_APP_DOWNLOAD_URL, {
      //   obj: {
      //     url:
      //       process.env.VUE_APP_BASE_URL +
      //       process.env.VUE_APP_FILE_PATH +
      //       this.obj.craftsFile
      //   }
      // }).then((res) => {
      //   // let disposition = res.headers['content-disposition']
      //   //   .replace(/\"/g, '')
      //   //   .split('=')
      //   // let fileName = decodeURI(disposition[disposition.length - 1])
      //   // let blob = new Blob([res.data], { type: res.data.type })
      //    let downloadElement = document.createElement('a')
      //   let href = window.URL.createObjectURL("http://127.0.0.1:82/welder-second/upload/5dd7751a5c55fd3473ba375f/d/20230720/6b950997-dc4c-441a-9f68-2dd9aa29a23a.pdf") // 创建下载的链接
      //   downloadElement.href = href
      //   downloadElement.download = "3213" // 下载后文件名
      //   document.body.appendChild(downloadElement)
      //   downloadElement.click() // 点击下载
      //   document.body.removeChild(downloadElement) // 下载完成移除元素
      //   window.URL.revokeObjectURL(href) // 释放blob对象
      // })
    }
  }
}
</script>

<style scoped>
</style>
